#include<bits/stdc++.h>
using namespace std;
const int N=5e5+5;
int n,m,root,root1,w,o,oo,ooo,oooo,ooooo,oooooo,qwq,l,r,z[N*2-5],top,op,op1,po[N],po1[N],bj[N],top1,top2,top3,top4,orz;
char a;
struct node{
	int l,r,z,z1,k;
}treap[N*2-5];
struct node1{
	int l,r;
}b[N],c[N];
bool cmp(node1 i,node1 j)
{
	if(i.l==j.l) return i.r<j.r;
	return i.l<j.l;
}
int mke(int i,int j)
{
	if(z[top]) w=z[top],--top;
	else ++o,w=o;
	treap[w].k=rand();
	treap[w].l=treap[w].r=0;
	treap[w].z=i;
	treap[w].z1=j;
	return w;
}
void spilt(int i,int j,int j1,int &l,int &r)
{
	if(!i)
	{
		l=r=0;
		return;
	}
	if(treap[i].z<j||(treap[i].z==j&&treap[i].z1<=j1))
	{
		l=i;
		spilt(treap[l].r,j,j1,treap[l].r,r);
	}
	else{
		r=i;
		spilt(treap[r].l,j,j1,l,treap[r].l);
	}
}
int marge(int l,int r)
{
	if(!l||!r) return l+r;
	if(treap[l].k<=treap[r].k)
	{
		treap[r].l=marge(l,treap[r].l);
		return r;
	}
	else{
		treap[l].r=marge(treap[l].r,r);
		return l;
	}
}
int cx(int i)
{
	while(treap[i].l)
		i=treap[i].l;
	return i;
}
int cx1(int i)
{
	while(treap[i].r)
		i=treap[i].r;
	return i;
}
int main()
{
	freopen("stone.in","r",stdin);
	freopen("stone.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	if(n<=500)
		for(int i=1;i<=n;++i)
		{
			cin>>a>>l>>r;
			if(a=='A')
			{
				++top;
				if(l>=r) ++orz;
				po[top]=l,po1[top]=r;
				for(int j=1;j<=top;++j)
					if(!bj[j])
					{
						++top1;
						b[top1].l=max(0,min(r,po1[j])-max(l,po[j]));
						b[top1].r=max(po1[j]-l,r-po[j]);
					}
			}
			else{
				if(l>=r) --orz;
				for(int j=1;j<=top;++j)
					if(!bj[j])
					{
						++top2;
						c[top2].l=max(0,min(r,po1[j])-max(l,po[j]));
						c[top2].r=max(po1[j]-l,r-po[j]);
					}
				for(int j=1;j<=top;++j)
					if(!bj[j]&&po[j]==l&&po1[j]==r)
					{
						bj[j]=1;
						break;
					}
			}
			if(orz)
				cout<<0<<'\n';
			else
			{
				sort(b+1,b+top1+1,cmp);
				sort(c+1,c+top2+1,cmp);
				top3=1;
				for(int j=1;j<=top1;++j)
				{
					if(b[j].l==c[top3].l&&b[j].r==c[top3].r)
						++top3;
					else{
						cout<<b[j].r<<'\n';
						break;
					}
				}
			}
		}
	else
		for(int i=1;i<=n;++i)
		{
			cin>>a>>l>>r;
			if(a=='A')
			{
				if(l>=r) ++orz;
				++qwq;
				spilt(root,l,r,oo,ooo);
				if(oo)
				{
					op=cx1(oo);
					spilt(root1,0,r-treap[op].z,oooo,ooooo);
					root1=marge(oooo,marge(mke(0,r-treap[op].z),ooooo));
				}
				if(ooo)
				{
					op=cx(ooo);
					spilt(root1,0,treap[op].z1-l,oooo,ooooo);
					root1=marge(oooo,marge(mke(0,treap[op].z1-l),ooooo));
				}
				root=marge(oo,marge(mke(l,r),ooo));
			}
			else{
				if(l>=r) --orz;
				--qwq;
				spilt(root,l,r,ooo,oooo);
				spilt(ooo,l,r-1,oo,ooo);
				++top;
				z[top]=ooo;
				if(oo)
				{
					op=cx1(oo);
					spilt(root1,0,r-treap[op].z,ooooo,oooooo);
					spilt(ooooo,0,r-treap[op].z-1,ooo,ooooo);
					++top;
					z[top]=ooooo;
					ooooo=marge(treap[ooooo].l,treap[ooooo].r);
					root1=marge(ooo,marge(ooooo,oooooo));
				}
				if(oooo)
				{
					op=cx(oooo);
					spilt(root1,0,treap[op].z1-l,ooooo,oooooo);
					spilt(ooooo,0,treap[op].z1-l-1,ooo,ooooo);
					++top;
					z[top]=ooooo;
					ooooo=marge(treap[ooooo].l,treap[ooooo].r);
					root1=marge(ooo,marge(ooooo,oooooo));
				}
				if(oo&&oooo)
				{
					op=cx1(oo);
					op1=cx(oooo);
					spilt(root1,0,treap[op1].z1-treap[op].z,ooo,ooooo);
					root1=marge(ooo,marge(mke(0,treap[op1].z1-treap[op].z),ooooo));
				}
			}
			if(orz) cout<<0<<'\n';
			else if(qwq==1)
				cout<<treap[root].z1-treap[root].z<<'\n';
			else
				cout<<treap[cx(root1)].z1<<'\n';
		}
	return 0;
}
